package day02;

// Prototype接口继承的Cloneable这个接口
interface Prototype extends Cloneable {
    Prototype clone() throws CloneNotSupportedException;
}

// 实现类
class Person implements Prototype {
    private String name;
    private int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public Person clone() throws CloneNotSupportedException {
        return (Person) super.clone();
    }

    @Override
    public String toString() {
        return String.format("姓名:%s, 年龄:%s", name, age);
    }
}

public class BooleanDemo {
    public static void main(String[] args) throws CloneNotSupportedException {
        Person p1 = new Person("张二", 20);
        Person p2 = p1.clone();
        System.out.println(p1);
        System.out.println(p2);
        System.out.println(p1 == p2);
    }
}